<%@page import="com.jin.blog.util.Base64Coder"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="com.jin.blog.util.Base64Coder,org.json.JSONObject"%>
<%
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    String upload_ret = request.getParameter("upload_ret");
    JSONObject json = new JSONObject();
    if(upload_ret == null){
    	json.put("state", request.getParameter("error"));
    }else{
	    JSONObject callback = new JSONObject(Base64Coder.decode(upload_ret));
	    if (callback.has("error")) {
	        json.put("state", callback.get("error"));
	    } else {
	        json.put("original", callback.get("name"));
	        json.put("name", callback.get("key"));
	        json.put("url", callback.get("key") + "-thumbfit.jpg");
	        json.put("size", callback.get("size"));
	        json.put("type", callback.get("type"));
	        json.put("state", "SUCCESS");
	    }
    }
    response.getWriter().print(json.toString());
%>